package com.api.shopapi.mapper;


import com.api.shopapi.entity.OrderTradeno;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface OrderTradenoMapper {

    @Insert("insert into order_tradeno value" +
            "(" +
            "#{orderTradeno.OrderTradenoCode}," +
            "#{orderTradeno.UserCode}," +
            "#{orderTradeno.TradeNo}," +
            "#{orderTradeno.Price}," +
            "#{orderTradeno.CreateTime}," +
            "#{orderTradeno.Status},"+
            "#{orderTradeno.PayType}," +
            "#{orderTradeno.ClientType}" +
            ")")
    public int insert(@Param("orderTradeno") OrderTradeno orderTradeno);

    @Delete("delete from order_tradeno where OrderTradenoCode=#{orderTradenoCode}")
    public int delete(@Param("orderTradenoCode") String orderTradenoCode);

    @Update("update order_tradeno set " +
            "Status = #{orderTradeno.Status}," +
            "UserCode = #{orderTradeno.UserCode}," +
            "TradeNo = #{orderTradeno.TradeNo}," +
            "Price = #{orderTradeno.Price}," +
            "PayType = #{orderTradeno.PayType}," +
            "ClientType = #{orderTradeno.ClientType} "+
            " where OrderTradenoCode=#{orderTradeno.orderTradenoCode}")
    public int update(@Param("orderTradeno") OrderTradeno orderTradeno);

    @Select("select * from order_tradeno order by CreateTime desc")
    public List<OrderTradeno> getList();

    @Select("select * from order_tradeno where OrderTradeNoCode=#{orderTradeNoCode} limit 1")
    public OrderTradeno getByOrderTradenoCode(@Param("orderTradeNoCode") String orderTradeNoCode);

    @Select("select * from order_tradeno where tradeno=#{tradeno} limit 1")
    public OrderTradeno getByTradeno(@Param("tradeno") String tradeno);

}
